package com.example.shiwu.util;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUtii {
    public static void putSharedPreferences(String key,String value,Context context){
        // 存储数据
        SharedPreferences sharedPref = context.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putString(key, value);
        editor.apply();
    }

    public static String getSharedPreferences(String key,Context context){
        // 读取数据
        SharedPreferences sharedPref = context.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
        String value = sharedPref.getString(key, "default_value");
        return value;
    }
}
